package com.yibai.web.admin.qiniu;
import com.qiniu.util.Auth;
import com.yibai.web.app.config.AppConfig;
import com.yibai.web.dto.SuperRequest;
import com.yibai.web.dto.SuperResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author fang
 * @date 2019/10/15 18:09
 **/
@CrossOrigin(maxAge = 3600)
@RestController
@Api(value = "后台-七牛相关接口" ,description ="后台-七牛相关接口")
@RequestMapping("/web/upload/")
public class QiniuController {

    private Auth auth = null;


//    /**
//     * 七牛文档地址
//     * https://developer.qiniu.com/kodo/manual/1272/form-upload
//     */
//

    @ResponseBody
    @ApiOperation(value="获取后台图片上传token √", notes="")
    @RequestMapping(value = "/getWebUploadToken", method = RequestMethod.POST)
    public SuperResponse getWebUploadToken(@RequestBody SuperRequest request) {
        SuperResponse response = new SuperResponse();
        auth = Auth.create(AppConfig.ACCESS_KEY, AppConfig.SECRET_KEY);
        response.setToken(auth.uploadToken(AppConfig.bucket_web));
        return response;
    }

}
